<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all"/>
    <link rel="stylesheet" href="__CSS__/admin.css" media="all">
    <!-- <link rel="stylesheet" href="__CSS__/bootstrap.min.css" media="all"> -->
    <style type="text/css">

        /* tooltip */
        #tooltip {
            position: absolute;
            border: 1px solid #ccc;
            background: #333;
            padding: 2px;
            display: none;
            color: #fff;
        }

        .user_login{
            color:red;
        }

    </style>
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this">用户管理</li>
            <li><a href="{:url('admin/user/publish')}" class="a_menu">新增/修改用户</a></li>
        </ul>
    </div>
    <form class="layui-form serch">
        <div class="layui-form-item" style="float: left;">
            <div class="layui-input-inline">
                <input type="text" name="nickname" id="nickname"  autocomplete="off"
                       placeholder="请输入用戶昵称"
                       class="layui-input layui-btn-sm">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="phone" id="phone" autocomplete="off"
                       placeholder="请输入手机号"
                       class="layui-input layui-btn-sm">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="pphone" id="pphone" autocomplete="off"
                       placeholder="请输入推荐人手机号"
                       class="layui-input layui-btn-sm">
            </div>
            <div class="layui-input-inline">
                <select name="type" id="type" autocomplete="off" class="layui-input layui-btn-sm" >
                    <option value="">未选择</option>
                    <option value="1">无效节点</option>
                    <option value="2">有效节点</option>
                </select>
            </div>
            

            <div class="layui-inline">
                <input type="date" class="layui-input" name="start" id="start">
            </div>
            到
            <div class="layui-inline">
                <input type="date" class="layui-input" name="end" id="end">
            </div>

            <button class="layui-btn layui-btn-danger layui-btn-sm" id="lay_search" type="button" lay-filter="serch">立即提交</button>
        </div>
    </form>
    <hr class="layui-bg-blue">
    <!--表格-->
    <table class="layui-table" id="lay_table" ></table>
    <!--表格结束-->

    {include file="public/foot"}

    <!-- 用户详情 -->
    <div class="layui-table" id="user_detail" style="display:none;font-size:16px;">
        <table>
            <tr>
                <td>用户手机号：</td>
                <td class="detail_phone"></td>
            </tr>
            <tr>
                <td>昵称：</td>
                <td class="detail_nickname"></td>
            </tr>
            <tr>
                <td>真实姓名：</td>
                <td class="detail_truename"></td>
            </tr>
            <tr>
                <td>性别：</td>
                <td class="detail_sex"></td>
            </tr>
            <tr>
                <td>钱包地址：</td>
                <td class="detail_qrcode"></td>
            </tr>


            <tr>
                <td>消费基金：</td>
                <td class="detail_score"></td>
            </tr>
            <tr>
                <td>余额：</td>
                <td class="detail_balance"></td>
            </tr>
            <tr>
                <td>注册时间：</td>
                <td class="detail_create_time"></td>
            </tr>
            <tr>
                <td>最近登录时间：</td>
                <td class="detail_update_time"></td>
            </tr>
        </table>
    </div>
    <!-- 用户详情结束 -->
    <script type="text/javascript">
/*
        socket.on('user_is_login',function (res) {
            if(res.data){
                for(var i in res.data){
                    $('#is_login_'+res.data[i]).html('<a class="user_login" onclick="user_logout('+res.data[i]+')">上线</a>');
                }
            }
        });

        socket.on('user_login',function(res){
            if($('#is_login_'+res.user)){
                $('#is_login_'+res.user).html('<a class="user_login" onclick="user_logout('+res.user+')">上线</a>');
            }
        });

        socket.on('user_logout',function(res){
            if($('#is_login_'+res.user)){
                $('#is_login_'+res.user).text('下线');
            }
        });

        //踢下线
        function user_logout(id){
            layer.prompt({title: '写出踢TA下线的原因，并确认', formType: 2}, function(text, index){
                layer.close(index);
                socket.emit('user_logout',{user:id,text:text,pwd:parent.pwd});
                layer.msg('账号【'+id+'】已被踢下线')
            });
        }*/

        //表格需要数据
        function table_need() {
            return [[ //表头
                {field: 'id', title: 'ID', width:50, sort: true, fixed: 'left'},
                {field: 'nickname', title: '昵称'},
                {field: 'truename', title: '真实姓名'},
                {field: 'parent', title: '推荐人手机号'},
                {field: 'parent_name', title: '推荐人'},
                {field: 'phone', title: '手机号'},
                {field: 'stack', title: '钱包地址'},
                {field: 'activity_pool', title: '活动账户'},
                {field: 'pool', title: '矿池'},
                {field: 'type', title: '节点状态'},
                {field: 'create_time', title: '添加时间'},
                {field: 'operation', title: '操作',fixed: 'right'},
            ]]
        }

        //搜索条件
        function search_content() {
            //要求搜索表单id必须和搜索条件一致
            return [
                "nickname","phone","pphone","type","start","end"
            ]
        }
        table_init(table_need(),search_content(),"/admin/user/index");

        //用户详情
        function user_detail(id){
            $.getJSON("/admin/user/detail", {'id' : id}, function(res){
                var user = res.user;
                user.sex = user.sex == 1?'男':'女';
                $('.detail_phone').text(user.phone);
                $('.detail_nickname').text(user.nickname);
                $('.detail_truename').text(user.truename?user.truename:'');
                $('.detail_sex').text(user.sex);
                $('.detail_qrcode').text(user.stack);
                $('.detail_score').text(user.activity_pool);
                $('.detail_balance').text(user.pool);
                $('.detail_create_time').text(user.create_time);
                $('.detail_update_time').text(user.update_time);
                //捕获页
                layer.open({
                    type: 1,
                    shade: false,
                    area: ['400px', '500px'], //宽高
                    title: '用户详情', //不显示标题
                    content: $('#user_detail'),
                });
            });
        }
        function childs(id){
            tableIns.reload({
                    where: {"pid":id},
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
        }
        function edit(id){
            location.href = "/admin/user/publish?id="+id
        }

        /*//锁定解锁账号
        function lock(id,status){
            layer.confirm('你确定要执行此操作吗?', {icon: 3, title:'锁定/解锁账号'}, function(index){
                $.getJSON("./lock", {'id' : id}, function(res){
                    layer.msg("修改成功");
                    var update_status = res.status == 1 ? '禁用' : '正常';
                    $('.user_status_'+id).text(update_status)
                });
            });
        }*/


    </script>


</div>
</body>
</html>
